package wwiii;

public class Link {
	final Area a, b;
	final int l2;

	Link crossedBy = null;
	Area closeTo = null;

	public Link(Area a, Area b) {
		this.a = a;
		this.b = b;

		int dx = a.getX() - b.getX();
		int dy = a.getY() - b.getY();

		this.l2 = dx*dx + dy*dy;
	}

	public Area getAreaA() { return a; }
	public Area getAreaB() { return b; }

	public boolean isOK() { return !isCrossed() && !isClosed(); }
	public boolean isCrossed() { return crossedBy != null; }
	public boolean isClosed() { return closeTo != null; }

	@Override
	public String toString() {
		return "[Link "+l2+"]";
	}
}
